
const FullPageModules = import.meta.glob<false, 'url', any>('../pages/**/*.tsx')
/**
 * 给出src/pages 目录下的页面级别组件
 * 传入的basePath,会在返回的函数形参subPath之前,自动加上这个basePath(闭包)
 * @param basePath 基础路径 
 * @returns 
 */
function getPageBasePath(basePath: string) {
  if (!basePath.startsWith('/')) {
    basePath = `/${basePath}`
  }
  const basepath = `../pages${basePath}`
  return <T = any>(subPath: string): (() => Promise<any>) => FullPageModules[basepath + subPath]
}
function getLazeyPageByBaseName(str: string) {
  const func = getPageBasePath(str)
  return <T = any>(path: string) => (func<T>(path))
}

export { getLazeyPageByBaseName }